﻿package stfei.HorizList
{
    /**
    * 具体实现模板类的抽象
    */
    import flash.display.Loader;
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.net.URLRequest;
    
    import stfei.HorizList.Obj.*;
    import stfei.HorizList.core.*;
    import stfei.Preloader;
    public class ProductList extends HorizList
    {
        public function ProductList(mcW:Number , mcH:Number)
        {
            super(mcW , mcH )
        }
        protected override function getParseXml():IparseXml
        {
            return new inXML();
        }
        protected override function getRegPoint():IRegPoint
        {
            var RegPoint:RegPointList = new RegPointList();
            RegPoint.mcW = _MCW;
            RegPoint.mcH = _MCH;
            RegPoint._listColumn = _listColumn;
            RegPoint._listRow = _listRow;
            return RegPoint;
        }
        protected override function crateMovieClip(tol:Number):void
        {
            var ay:Number = RegPointArr[tol - 1][1];
            var ax:Number = RegPointArr[tol - 1][0];
            var loadPath:String = DataArr[tol - 1][0];
            var urlPath:String = DataArr[tol - 1][1];
            //var inimg:MovieClip = new MovieClip();
            var inimg:MovieClip = new listConMC
            inimg.buttonMode = true;
            inimg.x = ax;
            inimg.y = ay;
            inimg.myUrl = urlPath;
            inimg.addEventListener(MouseEvent.CLICK , onRe);
            inimg.addEventListener(MouseEvent.MOUSE_OVER , onOver);
            inimg.addEventListener(MouseEvent.MOUSE_OUT , onOut);
            try
            {
                _listMc.addChild(inimg);
            }catch (err:Error)
            {
                trace("加入父影片MC错误 " + err);
            }
            var loader:Loader = new Loader();
            loader.load(new URLRequest(loadPath));
            loader.name = "load"
            var preLoader:Preloader = new Preloader(loader , inimg.loaMC);
            preLoader.addEventListener(Preloader.LOADOVER , Lad);
            inimg.loaMC.addChild(loader);
        }
        //为影片添加鼠标事件
        private function onRe(eve:MouseEvent):void
        {
            trace(eve.currentTarget.myUrl);
        }
        private function onOver(eve:MouseEvent):void
        {
            var obj:Object = eve.currentTarget.loaMC.getChildByName("load");
            obj.alpha = 0.5;
        }
        private function onOut(eve:MouseEvent):void
        {
            //移出鼠标
            var obj:Object = eve.currentTarget.loaMC.getChildByName("load");
            obj.alpha = 1;
        }
        private function Lad(eve:Event):void
        {
            var obj:Loader = eve.target.loadMC;
            obj.alpha = 0;
            obj.addEventListener(Event.ENTER_FRAME , effect);
            //加载完成执行事件
        }
        private function effect(e:Event)
        {
            var obj:Object = e.currentTarget;
            obj.alpha += 0.05;
            if (obj.alpha > 1)
            {
                obj.removeEventListener(Event.ENTER_FRAME , effect);
            }
        }
    }
}
